2f6b9927f55d835674b870b430238da48597d328
[lhc/web/wiklou.git] / config / index.php
1 <?php
2 # MediaWiki web-based config/installation
3 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
4 # http://www.mediawiki.org/
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # http://www.gnu.org/copyleft/gpl.html
20
21 error_reporting( E_ALL );
22 header( "Content-type: text/html; charset=utf-8" );
23 @ini_set( "display_errors", true );
24
25 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26 "http://www.w3.org/TR/html4/loose.dtd">
27 <html>
28 <head>
29 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
30 <title>MediaWiki installation</title>
31 <style type="text/css">
32
33 @import "../skins/monobook/main.css";
34
35 .env-check {
36 font-size: 90%;
37 margin: 1em 0 1em 2.5em;
38 }
39
40 .config-section {
41 margin-top: 2em;
42 }
43
44 .config-section label.column {
45 clear: left;
46 font-weight: bold;
47 width: 13em;
48 float: left;
49 text-align: right;
50 padding-right: 1em;
51 padding-top: .2em;
52 }
53
54 .config-input {
55 clear: left;
56 zoom: 100%; /* IE hack */
57 }
58
59 .config-section .config-desc {
60 clear: left;
61 margin: 0 0 2em 18em;
62 padding-top: 1em;
63 font-size: 85%;
64 }
65
66 .iput-text, .iput-password {
67 width: 14em;
68 margin-right: 1em;
69 }
70
71 .error {
72 color: red;
73 background-color: #fff;
74 font-weight: bold;
75 left: 1em;
76 font-size: 100%;
77 }
78
79 .error-top {
80 color: red;
81 background-color: #FFF0F0;
82 border: 2px solid red;
83 font-size: 130%;
84 font-weight: bold;
85 padding: 1em 1.5em;
86 margin: 2em 0 1em;
87 }
88
89 ul.plain {
90 list-style-type: none;
91 list-style-image: none;
92 float: left;
93 margin: 0;
94 padding: 0;
95 }
96
97 .btn-install {
98 font-weight: bold;
99 font-size: 110%;
100 padding: .2em .3em;
101 }
102
103 .license {
104 font-size: 85%;
105 padding-top: 3em;
106 }
107
108 </style>
109 </head>
110
111 <body>
112 <div id="globalWrapper">
113 <div id="column-content">
114 <div id="content">
115 <div id="bodyContent">
116
117
118 <?php
119
120 # Relative includes seem to break if a parent directory is not readable;
121 # this is common for public_html subdirs under user home directories.
122 #
123 # As a dirty hack, we'll try to set up the include path first.
124 #
125 $IP = dirname( dirname( __FILE__ ) );
126 $sep = PATH_SEPARATOR;
127 ini_set( "include_path", ".$sep$IP$sep$IP/includes$sep$IP/languages" );
128
129 define( "MEDIAWIKI", true );
130 define( "MEDIAWIKI_INSTALL", true );
131 require_once( "includes/Defines.php" );
132 require_once( "includes/DefaultSettings.php" );
133 require_once( "includes/MagicWord.php" );
134 require_once( "includes/Namespace.php" );
135 ?>
136
137 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
138
139 <?php
140
141 /* Check for existing configurations and bug out! */
142
143 if( file_exists( "../LocalSettings.php" ) ) {
144 dieout( " <p><strong>Setup has completed, <a href='../index.php'>your wiki</a> is configured.</strong></p>
145
146 <p>Please delete the /config directory for extra security.</p></div></div></div></div>" );
147 }
148
149 if( file_exists( "./LocalSettings.php" ) ) {
150 writeSuccessMessage();
151
152 dieout( '' );
153 }
154
155 if( !is_writable( "." ) ) {
156 dieout( "<h2>Can't write config file, aborting</h2>
157
158 <p>In order to configure the wiki you have to make the <tt>config</tt> subdirectory
159 writable by the web server. Once configuration is done you'll move the created
160 <tt>LocalSettings.php</tt> to the parent directory, and for added safety you can
161 then remove the <tt>config</tt> subdirectory entirely.</p>
162
163 <p>To make the directory writable on a Unix/Linux system:</p>
164
165 <pre>
166 cd <i>/path/to/wiki</i>
167 chmod a+w config
168 </pre>" );
169 }
170
171
172 require_once( "install-utils.inc" );
173 require_once( "maintenance/updaters.inc" );
174
175 class ConfigData {
176 function getEncoded( $data ) {
177 # removing latin1 support, no need...
178 return $data;
179 }
180 function getSitename() { return $this->getEncoded( $this->Sitename ); }
181 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
182 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
183 }
184
185 ?>
186
187 <h2>Checking environment...</h2>
188 <p><em>Please include all of the lines below when reporting installation problems.</em></p>
189 <ul class="env-check">
190 <?php
191 $endl = "
192 ";
193 $wgNoOutputBuffer = true;
194 $conf = new ConfigData;
195
196 install_version_checks();
197
198 print "<li>PHP " . phpversion() . " installed</li>\n";
199
200 if( ini_get( "register_globals" ) ) {
201 ?>
202 <li>
203 <div style="font-size:110%">
204 <strong class="error">Warning:</strong>
205 <strong>PHP's <tt><a href="http://php.net/register_globals">register_globals</a></tt> option is enabled. Disable it if you can.</strong>
206 </div>
207 MediaWiki will work, but your server is more exposed to PHP-based security vulnerabilities.
208 </li>
209 <?php
210 }
211
212 $fatal = false;
213
214 if( ini_get( "magic_quotes_runtime" ) ) {
215 $fatal = true;
216 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime'>magic_quotes_runtime</a> is active!</strong>
217 This option corrupts data input unpredictably; you cannot install or use
218 MediaWiki unless this option is disabled.
219 <?php
220 }
221
222 if( ini_get( "magic_quotes_sybase" ) ) {
223 $fatal = true;
224 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase'>magic_quotes_sybase</a> is active!</strong>
225 This option corrupts data input unpredictably; you cannot install or use
226 MediaWiki unless this option is disabled.
227 <?php
228 }
229
230 if( ini_get( "mbstring.func_overload" ) ) {
231 $fatal = true;
232 ?><li class='error'><strong>Fatal: <a href='http://www.php.net/manual/en/ref.mbstring.php#mbstring.overload'>mbstring.func_overload</a> is active!</strong>
233 This option causes errors and may corrupt data unpredictably;
234 you cannot install or use MediaWiki unless this option is disabled.
235 <?php
236 }
237
238 if( $fatal ) {
239 dieout( "</ul><p>Cannot install Mediawiki.</p>" );
240 }
241
242 if( ini_get( "safe_mode" ) ) {
243 $conf->safeMode = true;
244 ?>
245 <li><b class='error'>Warning:</b> <strong>PHP's
246 <a href='http://www.php.net/features.safe-mode'>safe mode</a> is active.</strong>
247 You may have problems caused by this, particularly if using image uploads.
248 </li>
249 <?php
250 } else {
251 $conf->safeMode = false;
252 }
253
254
255 $sapi = php_sapi_name();
256 $conf->prettyURLs = true;
257 print "<li>PHP server API is $sapi; ";
258 switch( $sapi ) {
259 case "apache":
260 case "apache2handler":
261 print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
262 break;
263 case "cgi":
264 case "cgi-fcgi":
265 case "apache2filter":
266 print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
267 $conf->prettyURLs = false;
268 break;
269 default:
270 print "unknown; using pretty URLs (<tt>index.php/Page_Title</tt>), if you have trouble change this in <tt>LocalSettings.php</tt>";
271 }
272 print "</li>\n";
273
274 $conf->xml = function_exists( "utf8_encode" );
275 if( $conf->xml ) {
276 print "<li>Have XML / Latin1-UTF-8 conversion support.</li>\n";
277 } else {
278 dieout( "PHP's XML module is missing; the wiki requires functions in
279 this module and won't work in this configuration.
280 If you're running Mandrake, install the php-xml package." );
281 }
282
283 $memlimit = ini_get( "memory_limit" );
284 $conf->raiseMemory = false;
285 if( empty( $memlimit ) || $memlimit == -1 ) {
286 print "<li>PHP is configured with no <tt>memory_limit</tt>.</li>\n";
287 } else {
288 print "<li>PHP's <tt>memory_limit</tt> is " . htmlspecialchars( $memlimit ) . ". <strong>If this is too low, installation may fail!</strong> ";
289 $n = intval( $memlimit );
290 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $memlimit ), $m ) ) {
291 $n = intval( $m[1] * (1024*1024) );
292 }
293 if( $n < 20*1024*1024 ) {
294 print "Attempting to raise limit to 20M... ";
295 if( false === ini_set( "memory_limit", "20M" ) ) {
296 print "failed.";
297 } else {
298 $conf->raiseMemory = true;
299 print "ok.";
300 }
301 }
302 print "</li>\n";
303 }
304
305 $conf->zlib = function_exists( "gzencode" );
306 if( $conf->zlib ) {
307 print "<li>Have zlib support; enabling output compression.</li>\n";
308 } else {
309 print "<li>No zlib support.</li>\n";
310 }
311
312 $conf->turck = function_exists( 'mmcache_get' );
313 if ( $conf->turck ) {
314 print "<li><a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> installed</li>\n";
315 }
316 $conf->eaccel = function_exists( 'eaccelerator_get' );
317 if ( $conf->eaccel ) {
318 $conf->turck = 'eaccelerator';
319 print "<li><a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> installed</li>\n";
320 }
321 if (!$conf->turck && !$conf->eaccel) {
322 print "<li>Neither <a href=\"http://turck-mmcache.sourceforge.net/\">Turck MMCache</a> nor <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator</a> are installed, " .
323 "can't use object caching functions</li>\n";
324 }
325
326 $conf->diff3 = false;
327 $diff3locations = array("/usr/bin", "/opt/csw/bin", "/usr/gnu/bin", "/usr/sfw/bin") + explode($sep, getenv("PATH"));
328 $diff3names = array("gdiff3", "diff3", "diff3.exe");
329
330 $diff3versioninfo = array('$1 --version 2>&1', 'diff3 (GNU diffutils)');
331 foreach ($diff3locations as $loc) {
332 $exe = locate_executable($loc, $diff3names, $diff3versioninfo);
333 if ($exe !== false) {
334 $conf->diff3 = $exe;
335 break;
336 }
337 }
338
339 if ($conf->diff3)
340 print "<li>Found GNU diff3: <tt>$conf->diff3</tt>.</li>";
341 else
342 print "<li>GNU diff3 not found.</li>";
343
344 $conf->ImageMagick = false;
345 $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
346 foreach( $imcheck as $dir ) {
347 $im = "$dir/convert";
348 if( file_exists( $im ) ) {
349 print "<li>Found ImageMagick: <tt>$im</tt>; image thumbnailing will be enabled if you enable uploads.</li>\n";
350 $conf->ImageMagick = $im;
351 break;
352 }
353 }
354
355 $conf->HaveGD = function_exists( "imagejpeg" );
356 if( $conf->HaveGD ) {
357 print "<li>Found GD graphics library built-in";
358 if( !$conf->ImageMagick ) {
359 print ", image thumbnailing will be enabled if you enable uploads";
360 }
361 print ".</li>\n";
362 } else {
363 if( !$conf->ImageMagick ) {
364 print "<li>Couldn't find GD library or ImageMagick; image thumbnailing disabled.</li>\n";
365 }
366 }
367
368 $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
369
370 # $conf->IP = "/Users/brion/Sites/inplace";
371 $conf->IP = dirname( dirname( __FILE__ ) );
372 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
373
374 # $conf->ScriptPath = "/~brion/inplace";
375 $conf->ScriptPath = preg_replace( '{^(.*)/config.*$}', '$1', $_SERVER["PHP_SELF"] ); # was SCRIPT_NAME
376 print "<li>Script URI path: <tt>" . htmlspecialchars( $conf->ScriptPath ) . "</tt></li>\n";
377
378 print "<li style='font-weight:bold;color:green;font-size:110%'>Environment checked. You can install MediaWiki.</li>\n";
379 $conf->posted = ($_SERVER["REQUEST_METHOD"] == "POST");
380
381 $conf->Sitename = ucfirst( importPost( "Sitename", "" ) );
382 $defaultEmail = empty( $_SERVER["SERVER_ADMIN"] )
383 ? 'root@localhost'
384 : $_SERVER["SERVER_ADMIN"];
385 $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail );
386 $conf->DBtype = importPost( "DBtype", "mysql" );
387 $conf->DBserver = importPost( "DBserver", "localhost" );
388 $conf->DBname = importPost( "DBname", "wikidb" );
389 $conf->DBuser = importPost( "DBuser", "wikiuser" );
390 $conf->DBpassword = importPost( "DBpassword" );
391 $conf->DBpassword2 = importPost( "DBpassword2" );
392 $conf->DBprefix = importPost( "DBprefix" );
393 $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false";
394 $conf->RootPW = importPost( "RootPW" );
395 $conf->LanguageCode = importPost( "LanguageCode", "en" );
396 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
397 $conf->SysopPass = importPost( "SysopPass" );
398 $conf->SysopPass2 = importPost( "SysopPass2" );
399
400 /* Check for validity */
401 $errs = array();
402
403 if( $conf->Sitename == "" || $conf->Sitename == "MediaWiki" || $conf->Sitename == "Mediawiki" ) {
404 $errs["Sitename"] = "Must not be blank or \"MediaWiki\"";
405 }
406 if( $conf->DBuser == "" ) {
407 $errs["DBuser"] = "Must not be blank";
408 }
409 if( $conf->DBpassword == "" ) {
410 $errs["DBpassword"] = "Must not be blank";
411 }
412 if( $conf->DBpassword != $conf->DBpassword2 ) {
413 $errs["DBpassword2"] = "Passwords don't match!";
414 }
415 if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) {
416 $errs["DBprefix"] = "Invalid table prefix";
417 }
418
419 if( $conf->SysopPass == "" ) {
420 $errs["SysopPass"] = "Must not be blank";
421 }
422 if( $conf->SysopPass != $conf->SysopPass2 ) {
423 $errs["SysopPass2"] = "Passwords don't match!";
424 }
425
426 $conf->License = importRequest( "License", "none" );
427 if( $conf->License == "gfdl" ) {
428 $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
429 $conf->RightsText = "GNU Free Documentation License 1.2";
430 $conf->RightsCode = "gfdl";
431 $conf->RightsIcon = '${wgStylePath}/common/images/gnu-fdl.png';
432 } elseif( $conf->License == "none" ) {
433 $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
434 } else {
435 $conf->RightsUrl = importRequest( "RightsUrl", "" );
436 $conf->RightsText = importRequest( "RightsText", "" );
437 $conf->RightsCode = importRequest( "RightsCode", "" );
438 $conf->RightsIcon = importRequest( "RightsIcon", "" );
439 }
440
441 $conf->Shm = importRequest( "Shm", "none" );
442 $conf->MCServers = importRequest( "MCServers" );
443
444 /* Test memcached servers */
445
446 if ( $conf->Shm == 'memcached' && $conf->MCServers ) {
447 $conf->MCServerArray = array_map( 'trim', explode( ',', $conf->MCServers ) );
448 foreach ( $conf->MCServerArray as $server ) {
449 $error = testMemcachedServer( $server );
450 if ( $error ) {
451 $errs["MCServers"] = $error;
452 break;
453 }
454 }
455 } else if ( $conf->Shm == 'memcached' ) {
456 $errs["MCServers"] = "Please specify at least one server if you wish to use memcached";
457 }
458
459 /* default values for installation */
460 $conf->Email =importRequest("Email", "email_enabled");
461 $conf->Emailuser=importRequest("Emailuser", "emailuser_enabled");
462 $conf->Enotif =importRequest("Enotif", "enotif_allpages");
463 $conf->Eauthent =importRequest("Eauthent", "eauthent_enabled");
464
465 if( $conf->posted && ( 0 == count( $errs ) ) ) {
466 do { /* So we can 'continue' to end prematurely */
467 $conf->Root = ($conf->RootPW != "");
468
469 /* Load up the settings and get installin' */
470 $local = writeLocalSettings( $conf );
471 $wgCommandLineMode = false;
472 chdir( ".." );
473 eval($local);
474 if (!in_array($conf->DBtype, array("mysql", "oracle"))) {
475 $errs["DBtype"] = "Unknown database type.";
476 continue;
477 }
478 print "<li>Database type: {$conf->DBtype}</li>\n";
479 $dbclass = 'Database'.ucfirst($conf->DBtype);
480 require_once("$dbclass.php");
481 $wgDBtype = $conf->DBtype;
482 $wgDBadminuser = "root";
483 $wgDBadminpassword = $conf->RootPW;
484 $wgDBprefix = $conf->DBprefix;
485 $wgCommandLineMode = true;
486 $wgUseDatabaseMessages = false; /* FIXME: For database failure */
487 require_once( "includes/Setup.php" );
488 chdir( "config" );
489
490 require_once( "maintenance/InitialiseMessages.inc" );
491
492 $wgTitle = Title::newFromText( "Installation script" );
493 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
494 if( $mysqlOldClient ) {
495 print "<li><b>PHP is linked with old MySQL client libraries. If you are
496 using a MySQL 4.1 server and have problems connecting to the database,
497 see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
498 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
499 }
500 $dbc = new $dbclass;
501 if ($conf->DBtype == 'mysql') {
502 print "<li>Trying to connect to database server on $wgDBserver as root...\n";
503 $wgDatabase = $dbc->newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
504
505 if( $wgDatabase->isOpen() ) {
506 $myver = get_db_version();
507 $wgDatabase->ignoreErrors(true);
508 $conf->Root = true;
509 print "<ul><li>Connected as root (automatic)</li></ul></li>\n";
510 } else {
511 print "<ul><li>MySQL error " . ($err = mysql_errno() ) .
512 ": " . htmlspecialchars( mysql_error() ) . "</li></ul></li>";
513 $ok = false;
514 switch( $err ) {
515 case 1045:
516 case 2000:
517 if( $conf->Root ) {
518 $errs["RootPW"] = "Check password";
519 } else {
520 print "<li>Trying regular user...\n";
521 /* Try the regular user... */
522 $wgDBadminuser = $wgDBuser;
523 $wgDBadminpassword = $wgDBpassword;
524 /* Wait one second for connection rate limiting, present on some systems */
525 sleep(1);
526 $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
527 if( !$wgDatabase->isOpen() ) {
528 print "<ul><li>MySQL error " . ($err = mysql_errno() ) .
529 ": " . htmlspecialchars( mysql_error() ) . "</li></ul></li>";
530 $errs["DBuser"] = "Check name/pass";
531 $errs["DBpassword"] = "or enter root";
532 $errs["DBpassword2"] = "password below";
533 $errs["RootPW"] = "Got root?";
534 } else {
535 $myver = mysql_get_server_info( $wgDatabase->mConn );
536 $wgDatabase->ignoreErrors(true);
537 $conf->Root = false;
538 $conf->RootPW = "";
539 print " ok.</li>\n";
540 # And keep going...
541 $ok = true;
542 }
543 break;
544 }
545 case 2002:
546 case 2003:
547 $errs["DBserver"] = "Connection failed";
548 break;
549 default:
550 $errs["DBserver"] = "Couldn't connect to database";
551 break;
552 }
553 if( !$ok ) continue;
554 }
555 } else /* not mysql */ {
556 print "<li>Connecting to SQL server...";
557 $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
558 if (!$wgDatabase->isOpen()) {
559 print " error: " . $wgDatabase->lastError() . "</li>\n";
560 } else {
561 $wgDatabase->ignoreErrors(true);
562 $myver = get_db_version();
563 }
564 }
565
566 if ( !$wgDatabase->isOpen() ) {
567 $errs["DBserver"] = "Couldn't connect to database";
568 continue;
569 }
570
571 print "<li>Connected to $myver";
572 if( version_compare( $myver, "4.0.0" ) < 0 ) {
573 die( " -- mysql 4.0 or later required. Aborting." );
574 }
575 $mysqlNewAuth = version_compare( $myver, "4.1.0", "ge" );
576 if( $mysqlNewAuth && $mysqlOldClient ) {
577 print "; <b class='error'>You are using MySQL 4.1 server, but PHP is linked
578 to old client libraries; if you have trouble with authentication, see
579 <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
580 >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
581 }
582 if( $wgDBmysql5 ) {
583 if( $mysqlNewAuth ) {
584 print "; enabling MySQL 4.1/5.0 charset mode";
585 } else {
586 print "; <b class='error'>MySQL 4.1/5.0 charset mode enabled,
587 but older version detected; will likely fail.</b>";
588 }
589 }
590 print "</li>\n";
591
592 if ($conf->DBtype == 'mysql') {
593 @$sel = mysql_select_db( $wgDBname, $wgDatabase->mConn );
594 if( $sel ) {
595 print "<li>Database <tt>" . htmlspecialchars( $wgDBname ) . "</tt> exists</li>\n";
596 } else {
597 $err = mysql_errno();
598 if ( $err != 1049 ) {
599 print "<ul><li>Error selecting database $wgDBname: $err " .
600 htmlspecialchars( mysql_error() ) . "</li></ul>";
601 continue;
602 }
603 $res = $wgDatabase->query( "CREATE DATABASE `$wgDBname`" );
604 if( !$res ) {
605 print "<li>Couldn't create database <tt>" .
606 htmlspecialchars( $wgDBname ) .
607 "</tt>; try with root access or check your username/pass.</li>\n";
608 $errs["RootPW"] = "&lt;- Enter";
609 continue;
610 }
611 print "<li>Created database <tt>" . htmlspecialchars( $wgDBname ) . "</tt></li>\n";
612 }
613 $wgDatabase->selectDB( $wgDBname );
614 }
615
616
617 if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) {
618 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
619
620 # Create user if required
621 if ( $conf->Root ) {
622 $conn = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
623 if ( $conn->isOpen() ) {
624 print "<li>DB user account ok</li>\n";
625 $conn->close();
626 } else {
627 print "<li>Granting user permissions...";
628 if( $mysqlOldClient && $mysqlNewAuth ) {
629 print " <b class='error'>If the next step fails, see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'>http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
630 }
631 print "</li>\n";
632 dbsource( "../maintenance/users.sql", $wgDatabase );
633 }
634 }
635 print "<pre>\n";
636 chdir( ".." );
637 flush();
638 do_all_updates();
639 chdir( "config" );
640
641 print "</pre>\n";
642 print "<li>Finished update checks.</li>\n";
643 } else {
644 # FIXME: Check for errors
645 print "<li>Creating tables...";
646 if ($conf->DBtype == 'mysql') {
647 if( $wgDBmysql5 ) {
648 print " using MySQL 5 table defs...";
649 dbsource( "../maintenance/mysql5/tables.sql", $wgDatabase );
650 } else {
651 print " using MySQL 4 table defs...";
652 dbsource( "../maintenance/tables.sql", $wgDatabase );
653 }
654 dbsource( "../maintenance/interwiki.sql", $wgDatabase );
655 } else {
656 dbsource( "../maintenance/oracle/tables.sql", $wgDatabase );
657 dbsource( "../maintenance/oracle/interwiki.sql", $wgDatabase );
658 }
659
660 print " done.</li>\n";
661
662 print "<li>Initializing data...";
663 $wgDatabase->insert( 'site_stats',
664 array( 'ss_row_id' => 1,
665 'ss_total_views' => 0,
666 'ss_total_edits' => 0,
667 'ss_good_articles' => 0 ) );
668 # setting up the db user
669 if( $conf->Root ) {
670 print "<li>Granting user permissions...</li>\n";
671 dbsource( "../maintenance/users.sql", $wgDatabase );
672 }
673
674 if( $conf->SysopName ) {
675 $u = User::newFromName( $conf->getSysopName() );
676 if ( 0 == $u->idForName() ) {
677 $u->addToDatabase();
678 $u->setPassword( $conf->getSysopPass() );
679 $u->saveSettings();
680
681 $u->addGroup( "sysop" );
682 $u->addGroup( "bureaucrat" );
683
684 print "<li>Created sysop account <tt>" .
685 htmlspecialchars( $conf->SysopName ) . "</tt>.</li>\n";
686 } else {
687 print "<li>Could not create user - already exists!</li>\n";
688 }
689 } else {
690 print "<li>Skipped sysop account creation, no name given.</li>\n";
691 }
692
693 $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) );
694 $article = new Article( $titleobj );
695 $newid = $article->insertOn( $wgDatabase );
696 $revision = new Revision( array(
697 'page' => $newid,
698 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ),
699 'comment' => '',
700 'user' => 0,
701 'user_text' => 'MediaWiki default',
702 ) );
703 $revid = $revision->insertOn( $wgDatabase );
704 $article->updateRevisionOn( $wgDatabase, $revision );
705
706 print "<li><pre>";
707 initialiseMessages();
708 print "</pre></li>\n";
709 }
710
711 /* Write out the config file now that all is well */
712 print "<p>Creating LocalSettings.php...</p>\n\n";
713 $localSettings = "<" . "?php$endl$local$endl?" . ">";
714 // Fix up a common line-ending problem (due to CVS on Windows)
715 $localSettings = str_replace( "\r\n", "\n", $localSettings );
716
717 if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
718 $xt = "xt"; # Refuse to overwrite an existing file
719 } else {
720 $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
721 }
722 $f = fopen( "LocalSettings.php", $xt );
723
724 if( $f == false ) {
725 dieout( "<p>Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" .
726 "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
727 "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
728 }
729 if(fwrite( $f, $localSettings ) ) {
730 fclose( $f );
731 writeSuccessMessage();
732 } else {
733 fclose( $f );
734 die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n");
735
736 }
737
738 } while( false );
739 }
740 ?>
741 </ul>
742
743
744 <?php
745
746 if( count( $errs ) ) {
747 /* Display options form */
748
749 if( $conf->posted ) {
750 echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n";
751 }
752 ?>
753
754 <form action="index.php" name="config" method="post">
755
756
757 <h2>Site config</h2>
758
759 <div class="config-section">
760 <div class="config-input">
761 <?php
762 aField( $conf, "Sitename", "Wiki name:" );
763 ?>
764 </div>
765 <p class="config-desc">
766 Preferably a short word without punctuation, i.e. "Wikipedia".<br>
767 Will appear as the namespace name for "meta" pages, and throughout the interface.
768 </p>
769
770 <div class="config-input">
771 <?php
772 aField( $conf, "EmergencyContact", "Contact e-mail:" );
773 ?>
774 </div>
775 <p class="config-desc">
776 Displayed to users in some error messages, used as the return address for password reminders, and used as the default sender address of e-mail notifications.
777 </p>
778
779 <div class="config-input">
780 <label class='column' for="LanguageCode">Language:</label>
781 <select id="LanguageCode" name="LanguageCode">
782
783 <?php
784 $list = getLanguageList();
785 foreach( $list as $code => $name ) {
786 $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : '';
787 echo "\t\t<option value=\"$code\" $sel>$name</option>\n";
788 }
789 ?>
790 </select>
791 </div>
792 <p class="config-desc">
793 Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) used for all localizations.
794 </p>
795
796 <div class="config-input">
797 <label class='column'>Copyright/license:</label>
798
799 <ul class="plain">
800 <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li>
801 <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
802 <li><?php
803 aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" );
804 $partner = "MediaWiki";
805 $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
806 $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
807 $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
808 print "<a href=\"$ccApp\" target='_blank'>choose</a>";
809 ?>
810 <?php if( $conf->License == "cc" ) { ?>
811 <ul>
812 <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon' />", "hidden" ); ?></li>
813 <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li>
814 <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li>
815 <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li>
816 </ul>
817 <?php } ?>
818 </li>
819 </ul>
820 </div>
821 <p class="config-desc">
822 A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick.
823 </p>
824
825
826 <div class="config-input">
827 <?php aField( $conf, "SysopName", "Admin username:" ) ?>
828 </div>
829 <div class="config-input">
830 <?php aField( $conf, "SysopPass", "Password:", "password" ) ?>
831 </div>
832 <div class="config-input">
833 <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?>
834 </div>
835 <p class="config-desc">
836 An admin can lock/delete pages, block users from editing, and other maintenance tasks.<br>
837 A new account will be added only when creating a new wiki database.
838 </p>
839
840 <div class="config-input">
841 <label class='column'>Shared memory caching:</label>
842
843 <ul class="plain">
844 <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li>
845 <?php
846 if ( $conf->turck ) {
847 echo "<li>";
848 aField( $conf, "Shm", "Turck MMCache", "radio", "turck" );
849 echo "</li>";
850 }
851 ?>
852 <?php
853 if ( $conf->eaccel ) {
854 echo "<li>";
855 aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" );
856 echo "</li>";
857 }
858 ?>
859 <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li>
860 </ul>
861 <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div>
862 </div>
863 <p class="config-desc">
864 Using a shared memory system such as Turck MMCache, eAccelerator, or Memcached will speed
865 up MediaWiki significantly. Memcached is the best solution but needs to be
866 installed. Specify the server addresses and ports in a comma-separted list. Only
867 use Turck shared memory if the wiki will be running on a single Apache server.
868 </p>
869 </div>
870
871 <h2>E-mail, e-mail notification and authentication setup</h2>
872
873 <div class="config-section">
874 <div class="config-input">
875 <label class='column'>E-mail (general):</label>
876 <ul class="plain">
877 <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li>
878 <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li>
879 </ul>
880 </div>
881 <p class="config-desc">
882 Use this to disable all e-mail functions (send a password reminder, user-to-user e-mail and e-mail notification),
883 if sending e-mails on your server doesn't work.
884 </p>
885 <div class="config-input">
886 <label class='column'>User-to-user e-mail:</label>
887 <ul class="plain">
888 <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li>
889 <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li>
890 </ul>
891 </div>
892 <p class="config-desc">
893 Use this to disable only the user-to-user e-mail function (EmailUser).
894 </p>
895 <div class="config-input">
896 <label class='column'>E-mail notification:</label>
897 <ul class="plain">
898 <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li>
899 <li><?php aField( $conf, "Enotif", "Enabled for user_talk changes only", "radio", "enotif_usertalk" ); ?></li>
900 <li><?php aField( $conf, "Enotif", "Enabled for user_talk and watch list changes (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li>
901 </ul>
902 </div>
903 <div class="config-desc">
904 <p>
905 E-mail notification sends a notification e-mail to a user, when the user_talk page is changed
906 and/or when watch-listed pages are changed, depending on the above settings.
907 When testing this feature, be reminded, that obviously an e-mail address must be present in your preferences
908 and that your own changes never trigger notifications to be sent to yourself.</p>
909
910 <p>Users get corresponding options to select or deselect in their users' preferences.
911 The user options are not shown on the preference page, if e-mail notification is disabled.</p>
912
913 <p>There are additional options for fine tuning in /includes/DefaultSettings.php .</p>
914 </div>
915
916 <div class="config-input">
917 <label class='column'>E-mail authentication:</label>
918 <ul class="plain">
919 <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li>
920 <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li>
921 </ul>
922 </div>
923 <div class="config-desc">
924 <p>E-mail address authentication uses a scheme to authenticate e-mail addresses of the users. The user who initially enters or changes his/her stored e-mail address
925 gets a link with a token mailed to that address. The stored e-mail address is authenticated at the moment the user comes back to the wiki via the link.</p>
926
927 <p>The e-mail address stays authenticated as long as the user does not change it; the time of authentication is indicated
928 on the user preference page.</p>
929
930 <p>If the option is enabled, only authenticated e-mail addresses can receive EmailUser mails and/or
931 e-mail notification mails.</p>
932 </div>
933
934 </div>
935
936 <h2>Database config</h2>
937
938 <div class="config-section">
939 <div class="config-input">
940 <label class='column'>Database type:</label>
941 <ul class='plain'>
942 <li><?php aField( $conf, "DBtype", "MySQL", "radio", "mysql"); ?></li>
943 <li><?php aField( $conf, "DBtype", "Oracle", "radio", "oracle" ); ?></li>
944 </ul>
945 </div>
946
947 <div class="config-input" style="clear:left"><?php
948 aField( $conf, "DBserver", "SQL server host:" );
949 ?></div>
950 <p class="config-desc">
951 If your database server isn't on your web server, enter the name
952 or IP address here. MySQL only.
953 </p>
954
955 <div class="config-input"><?php
956 aField( $conf, "DBname", "Database name:" );
957 ?></div>
958 <div class="config-desc">
959 If using Oracle, set this to your connection identifier.
960 </div>
961 <div class="config-input"><?php
962 aField( $conf, "DBuser", "DB username:" );
963 ?></div>
964 <div class="config-input"><?php
965 aField( $conf, "DBpassword", "DB password:", "password" );
966 ?></div>
967 <div class="config-input"><?php
968 aField( $conf, "DBpassword2", "DB password confirm:", "password" );
969 ?></div>
970 <p class="config-desc">
971 If you only have a single user account and database available,
972 enter those here. If you have database root access (see below)
973 you can specify new accounts/databases to be created.
974 </p>
975
976 <div class="config-input"><?php
977 aField( $conf, "DBprefix", "Database table prefix:" );
978 ?></div>
979 <div class="config-desc">
980 <p>If you need to share one database between multiple wikis, or
981 MediaWiki and another web application, you may choose to
982 add a prefix to all the table names to avoid conflicts.</p>
983
984 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
985 </div>
986
987 <div class="config-input"><label class="column">Database charset</label>
988 <div>Select one:</div>
989 <ul class="plain">
990 <li><?php aField( $conf, "DBmysql5", "Backwards-compatible UTF-8", "radio", "false" ); ?></li>
991 <li><?php aField( $conf, "DBmysql5", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "true" ); ?></li>
992 </ul>
993 </div>
994 <p class="config-desc">
995 <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support
996 for MySQL 4.1 and 5.0 servers. This is not well tested and may
997 cause things to break. <b>If upgrading an older installation, leave
998 in backwards-compatible mode.</b>
999 </p>
1000
1001 <div class="config-input">
1002 <?php
1003 aField( $conf, "RootPW", "DB root password:", "password" );
1004 ?>
1005 </div>
1006 <p class="config-desc">
1007 You will only need this if the database and/or user account
1008 above don't already exist.
1009 Do <em>not</em> type in your machine's root password! MySQL
1010 has its own "root" user with a separate password. (It might
1011 even be blank, depending on your configuration.)
1012 </p>
1013
1014 <div class="config-input" style="padding:2em 0 3em">
1015 <label class='column'>&nbsp;</label>
1016 <input type="submit" value="Install MediaWiki!" class="btn-install" />
1017 </div>
1018
1019 </div>
1020
1021 </form>
1022
1023 <?php
1024 }
1025
1026 /* -------------------------------------------------------------------------------------- */
1027 function writeSuccessMessage() {
1028 global $conf;
1029 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
1030 echo <<<EOT
1031 <p>Installation successful!</p>
1032 <p>To complete the installation, please do the following:
1033 <ol>
1034 <li>Download config/LocalSettings.php with your FTP client or file manager</li>
1035 <li>Upload it to the parent directory</li>
1036 <li>Delete config/LocalSettings.php</li>
1037 <li>Start using <a href='../index.php'>your wiki</a>!
1038 </ol>
1039 <p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.php
1040 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
1041 which means that anyone on the same server can read your database password! Downloading
1042 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
1043 EOT;
1044 } else {
1045 echo "<p>Installation successful! Move the config/LocalSettings.php file into the parent directory, then follow
1046 <a href='../index.php'>this link</a> to your wiki.</p>\n";
1047 }
1048 }
1049
1050
1051 function escapePhpString( $string ) {
1052 return strtr( $string,
1053 array(
1054 "\n" => "\\n",
1055 "\r" => "\\r",
1056 "\t" => "\\t",
1057 "\\" => "\\\\",
1058 "\$" => "\\\$",
1059 "\"" => "\\\""
1060 ));
1061 }
1062
1063 function writeLocalSettings( $conf ) {
1064 $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
1065 $conf->PasswordSender = $conf->EmergencyContact;
1066 $zlib = ($conf->zlib ? "" : "# ");
1067 $magic = ($conf->ImageMagick ? "" : "# ");
1068 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
1069 $pretty = ($conf->prettyURLs ? "" : "# ");
1070 $ugly = ($conf->prettyURLs ? "# " : "");
1071 $rights = ($conf->RightsUrl) ? "" : "# ";
1072 $hashedUploads = $conf->safeMode ? '' : '# ';
1073
1074 switch ( $conf->Shm ) {
1075 case 'memcached':
1076 $cacheType = 'CACHE_MEMCACHED';
1077 $mcservers = var_export( $conf->MCServerArray, true );
1078 break;
1079 case 'turck':
1080 case 'eaccel':
1081 $cacheType = 'CACHE_ACCEL';
1082 $mcservers = 'array()';
1083 break;
1084 default:
1085 $cacheType = 'CACHE_NONE';
1086 $mcservers = 'array()';
1087 }
1088
1089 if ( $conf->Email == 'email_enabled' ) {
1090 $enableemail = 'true';
1091 $enableuseremail = ( $conf->Emailuser == 'emailuser_enabled' ) ? 'true' : 'false' ;
1092 $eauthent = ( $conf->Eauthent == 'eauthent_enabled' ) ? 'true' : 'false' ;
1093 switch ( $conf->Enotif ) {
1094 case 'enotif_usertalk':
1095 $enotifusertalk = 'true';
1096 $enotifwatchlist = 'false';
1097 break;
1098 case 'enotif_allpages':
1099 $enotifusertalk = 'true';
1100 $enotifwatchlist = 'true';
1101 break;
1102 default:
1103 $enotifusertalk = 'false';
1104 $enotifwatchlist = 'false';
1105 }
1106 } else {
1107 $enableuseremail = 'false';
1108 $enableemail = 'false';
1109 $eauthent = 'false';
1110 $enotifusertalk = 'false';
1111 $enotifwatchlist = 'false';
1112 }
1113
1114 $file = @fopen( "/dev/urandom", "r" );
1115 if ( $file ) {
1116 $secretKey = bin2hex( fread( $file, 32 ) );
1117 fclose( $file );
1118 } else {
1119 $secretKey = "";
1120 for ( $i=0; $i<8; $i++ ) {
1121 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
1122 }
1123 print "<li>Warning: \$wgSecretKey key is insecure, generated with mt_rand(). Consider changing it manually.</li>\n";
1124 }
1125
1126 # Add slashes to strings for double quoting
1127 $slconf = array_map( "escapePhpString", get_object_vars( $conf ) );
1128 if( $conf->License == 'gfdl' ) {
1129 # Needs literal string interpolation for the current style path
1130 $slconf['RightsIcon'] = $conf->RightsIcon;
1131 }
1132
1133 $sep = PATH_SEPARATOR;
1134 $localsettings = "
1135 # This file was automatically generated by the MediaWiki installer.
1136 # If you make manual changes, please keep track in case you need to
1137 # recreate them later.
1138 #
1139 # See includes/DefaultSettings.php for all configurable settings
1140 # and their default values, but don't forget to make changes in _this_
1141 # file, not there.
1142
1143 \$IP = \"{$slconf['IP']}\";
1144 ini_set( \"include_path\", \".$sep\$IP$sep\$IP/includes$sep\$IP/languages\" );
1145 require_once( \"includes/DefaultSettings.php\" );
1146
1147 # If PHP's memory limit is very low, some operations may fail.
1148 " . ($conf->raiseMemory ? '' : '# ' ) . "ini_set( 'memory_limit', '20M' );" . "
1149
1150 if ( \$wgCommandLineMode ) {
1151 if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
1152 die( \"This script must be run from the command line\\n\" );
1153 }
1154 } elseif ( empty( \$wgNoOutputBuffer ) ) {
1155 ## Compress output if the browser supports it
1156 {$zlib}if( !ini_get( 'zlib.output_compression' ) ) @ob_start( 'ob_gzhandler' );
1157 }
1158
1159 \$wgSitename = \"{$slconf['Sitename']}\";
1160
1161 \$wgScriptPath = \"{$slconf['ScriptPath']}\";
1162 \$wgScript = \"\$wgScriptPath/index.php\";
1163 \$wgRedirectScript = \"\$wgScriptPath/redirect.php\";
1164
1165 ## If using PHP as a CGI module, use the ugly URLs
1166 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
1167 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
1168
1169 \$wgStylePath = \"\$wgScriptPath/skins\";
1170 \$wgStyleDirectory = \"\$IP/skins\";
1171 \$wgLogo = \"\$wgStylePath/common/images/wiki.png\";
1172
1173 \$wgUploadPath = \"\$wgScriptPath/images\";
1174 \$wgUploadDirectory = \"\$IP/images\";
1175
1176 \$wgEnableEmail = $enableemail;
1177 \$wgEnableUserEmail = $enableuseremail;
1178
1179 \$wgEmergencyContact = \"{$slconf['EmergencyContact']}\";
1180 \$wgPasswordSender = \"{$slconf['PasswordSender']}\";
1181
1182 ## For a detailed description of the following switches see
1183 ## http://meta.wikimedia.org/Enotif and http://meta.wikimedia.org/Eauthent
1184 ## There are many more options for fine tuning available see
1185 ## /includes/DefaultSettings.php
1186 ## UPO means: this is also a user preference option
1187 \$wgEnotifUserTalk = $enotifusertalk; # UPO
1188 \$wgEnotifWatchlist = $enotifwatchlist; # UPO
1189 \$wgEmailAuthentication = $eauthent;
1190
1191 \$wgDBserver = \"{$slconf['DBserver']}\";
1192 \$wgDBname = \"{$slconf['DBname']}\";
1193 \$wgDBuser = \"{$slconf['DBuser']}\";
1194 \$wgDBpassword = \"{$slconf['DBpassword']}\";
1195 \$wgDBprefix = \"{$slconf['DBprefix']}\";
1196 \$wgDBtype = \"{$slconf['DBtype']}\";
1197
1198 # Experimental charset support for MySQL 4.1/5.0.
1199 \$wgDBmysql5 = {$conf->DBmysql5};
1200
1201 ## Shared memory settings
1202 \$wgMainCacheType = $cacheType;
1203 \$wgMemCachedServers = $mcservers;
1204
1205 ## To enable image uploads, make sure the 'images' directory
1206 ## is writable, then uncomment this:
1207 # \$wgEnableUploads = true;
1208 \$wgUseImageResize = {$conf->UseImageResize};
1209 {$magic}\$wgUseImageMagick = true;
1210 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
1211
1212 ## If you want to use image uploads under safe mode,
1213 ## create the directories images/archive, images/thumb and
1214 ## images/temp, and make them all writable. Then uncomment
1215 ## this, if it's not already uncommented:
1216 {$hashedUploads}\$wgHashedUploadDirectory = false;
1217
1218 ## If you have the appropriate support software installed
1219 ## you can enable inline LaTeX equations:
1220 # \$wgUseTeX = true;
1221 \$wgMathPath = \"{\$wgUploadPath}/math\";
1222 \$wgMathDirectory = \"{\$wgUploadDirectory}/math\";
1223 \$wgTmpDirectory = \"{\$wgUploadDirectory}/tmp\";
1224
1225 \$wgLocalInterwiki = \$wgSitename;
1226
1227 \$wgLanguageCode = \"{$slconf['LanguageCode']}\";
1228
1229 \$wgProxyKey = \"$secretKey\";
1230
1231 ## Default skin: you can change the default skin. Use the internal symbolic
1232 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
1233 # \$wgDefaultSkin = 'monobook';
1234
1235 ## For attaching licensing metadata to pages, and displaying an
1236 ## appropriate copyright notice / icon. GNU Free Documentation
1237 ## License and Creative Commons licenses are supported so far.
1238 {$rights}\$wgEnableCreativeCommonsRdf = true;
1239 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
1240 \$wgRightsUrl = \"{$slconf['RightsUrl']}\";
1241 \$wgRightsText = \"{$slconf['RightsText']}\";
1242 \$wgRightsIcon = \"{$slconf['RightsIcon']}\";
1243 # \$wgRightsCode = \"{$slconf['RightsCode']}\"; # Not yet used
1244
1245 \$wgDiff3 = \"{$slconf['diff3']}\";
1246 ";
1247 // Keep things in Unix line endings internally;
1248 // the system will write out as local text type.
1249 return str_replace( "\r\n", "\n", $localsettings );
1250 }
1251
1252 function dieout( $text ) {
1253 die( $text . "\n\n</body>\n</html>" );
1254 }
1255
1256 function importVar( &$var, $name, $default = "" ) {
1257 if( isset( $var[$name] ) ) {
1258 $retval = $var[$name];
1259 if ( get_magic_quotes_gpc() ) {
1260 $retval = stripslashes( $retval );
1261 }
1262 } else {
1263 $retval = $default;
1264 }
1265 return $retval;
1266 }
1267
1268 function importPost( $name, $default = "" ) {
1269 return importVar( $_POST, $name, $default );
1270 }
1271
1272 function importRequest( $name, $default = "" ) {
1273 return importVar( $_REQUEST, $name, $default );
1274 }
1275
1276 $radioCount = 0;
1277
1278 function aField( &$conf, $field, $text, $type = "text", $value = "" ) {
1279 global $radioCount;
1280 if( $type != "" ) {
1281 $xtype = "type=\"$type\"";
1282 } else {
1283 $xtype = "";
1284 }
1285
1286 if(!(isset($id)) or ($id == "") ) $id = $field;
1287 $nolabel = ($type == "radio") || ($type == "hidden");
1288
1289 if ($type == 'radio')
1290 $id .= $radioCount++;
1291
1292 if( $nolabel ) {
1293 echo "\t\t<label>";
1294 } else {
1295 echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
1296 }
1297
1298 if( $type == "radio" && $value == $conf->$field ) {
1299 $checked = "checked='checked'";
1300 } else {
1301 $checked = "";
1302 }
1303 echo "\t\t<input $xtype name=\"$field\" id=\"$id\" class=\"iput-$type\" $checked value=\"";
1304 if( $type == "radio" ) {
1305 echo htmlspecialchars( $value );
1306 } else {
1307 echo htmlspecialchars( $conf->$field );
1308 }
1309 echo "\" />\n";
1310 if( $nolabel ) {
1311 echo " $text</label>\n";
1312 }
1313
1314 global $errs;
1315 if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
1316 }
1317
1318 function getLanguageList() {
1319 global $wgLanguageNames;
1320 if( !isset( $wgLanguageNames ) ) {
1321 $wgContLanguageCode = "xxx";
1322 function wfLocalUrl( $x ) { return $x; }
1323 function wfLocalUrlE( $x ) { return $x; }
1324 require_once( "languages/Names.php" );
1325 }
1326
1327 $codes = array();
1328
1329 $d = opendir( "../languages" );
1330 while( false !== ($f = readdir( $d ) ) ) {
1331 if( preg_match( '/Language([A-Z][a-z_]+)\.php$/', $f, $m ) ) {
1332 $code = str_replace( '_', '-', strtolower( $m[1] ) );
1333 if( isset( $wgLanguageNames[$code] ) ) {
1334 $name = $code . ' - ' . $wgLanguageNames[$code];
1335 } else {
1336 $name = $code;
1337 }
1338 $codes[$code] = $name;
1339 }
1340 }
1341 closedir( $d );
1342 ksort( $codes );
1343 return $codes;
1344 }
1345
1346 #Check for location of an executable
1347 # @param string $loc single location to check
1348 # @param array $names filenames to check for.
1349 # @param mixed $versioninfo array of details to use when checking version, use false for no version checking
1350 function locate_executable($loc, $names, $versioninfo = false) {
1351 if (!is_array($names))
1352 $names = array($names);
1353
1354 foreach ($names as $name) {
1355 $command = "$loc".DIRECTORY_SEPARATOR."$name";
1356 if (file_exists($command)) {
1357 if (!$versioninfo)
1358 return $command;
1359
1360 $file = str_replace('$1', $command, $versioninfo[0]);
1361 if (strstr(`$file`, $versioninfo[1]) !== false)
1362 return $command;
1363 }
1364 }
1365 return false;
1366 }
1367
1368 function get_db_version() {
1369 global $wgDatabase, $conf;
1370 if ($conf->DBtype == 'mysql')
1371 return mysql_get_server_info( $wgDatabase->mConn );
1372 else if ($conf->DBtype == 'oracle')
1373 return oci_server_version($wgDatabase->mConn);
1374 }
1375
1376 # Test a memcached server
1377 function testMemcachedServer( $server ) {
1378 $hostport = explode(":", $server);
1379 $errstr = false;
1380 $fp = false;
1381 if ( !function_exists( 'fsockopen' ) ) {
1382 $errstr = "Can't connect to memcached, fsockopen() not present";
1383 }
1384 if ( !$errstr && count( $hostport ) != 2 ) {
1385 $errstr = 'Please specify host and port';
1386 var_dump( $hostport );
1387 }
1388 if ( !$errstr ) {
1389 list( $host, $port ) = $hostport;
1390 $errno = 0;
1391 $fsockerr = '';
1392
1393 $fp = @fsockopen( $host, $port, $errno, $fsockerr, 1.0 );
1394 if ( $fp === false ) {
1395 $errstr = "Cannot connect to memcached on $host:$port : $fsockerr";
1396 }
1397 }
1398 if ( !$errstr ) {
1399 $command = "version\r\n";
1400 $bytes = fwrite( $fp, $command );
1401 if ( $bytes != strlen( $command ) ) {
1402 $errstr = "Cannot write to memcached socket on $host:$port";
1403 }
1404 }
1405 if ( !$errstr ) {
1406 $expected = "VERSION ";
1407 $response = fread( $fp, strlen( $expected ) );
1408 if ( $response != $expected ) {
1409 $errstr = "Didn't get correct memcached response from $host:$port";
1410 }
1411 }
1412 if ( $fp ) {
1413 fclose( $fp );
1414 }
1415 if ( !$errstr ) {
1416 echo "<li>Connected to memcached on $host:$port successfully";
1417 }
1418 return $errstr;
1419 }
1420 ?>
1421
1422 <div class="license">
1423 <hr>
1424 <p>This program is free software; you can redistribute it and/or modify
1425 it under the terms of the GNU General Public License as published by
1426 the Free Software Foundation; either version 2 of the License, or
1427 (at your option) any later version.</p>
1428
1429 <p>This program is distributed in the hope that it will be useful,
1430 but WITHOUT ANY WARRANTY; without even the implied warranty of
1431 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1432 GNU General Public License for more details.</p>
1433
1434 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
1435 along with this program; if not, write to the Free Software
1436 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1437 or <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a></p>
1438 </div>
1439
1440 </div></div></div>
1441
1442
1443 <div id="column-one">
1444 <div class="portlet" id="p-logo">
1445 <a style="background-image: url(../skins/common/images/mediawiki.png);"
1446 href="http://www.mediawiki.org/"
1447 title="Main Page"></a>
1448 </div>
1449 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
1450 <div class='portlet'><div class='pBody'>
1451 <ul>
1452 <li><strong><a href="http://www.mediawiki.org/">MediaWiki home</a></strong></li>
1453 <li><a href="../README">Readme</a></li>
1454 <li><a href="../RELEASE-NOTES">Release notes</a></li>
1455 <li><a href="../docs/">Documentation</a></li>
1456 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
1457 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
1458 </ul>
1459 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright &copy; 2001-2005 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik M&ouml;ller, Gabriel Wicke and others.</p>
1460 </div></div>
1461 </div>
1462
1463 </div>
1464
1465 </body>
1466 </html>